<?php
/**
* 分类服务
*/
class JddjCategorySvc extends JddjCommon
{
    
    /** 创建药品分类
     * @param $pid 父分类ID，若增加一级店内分类，父分类id为0
     * @param $shopCategoryName 店内分类名称
     */
    public function addShopCategory($pid, $shopCategoryName)
    {
        $data = array();
        $data['pid'] = $pid;
        $data['shopCategoryName'] = $shopCategoryName;

        return $data;
    }
    /** 
     * 发送创建药品分类
     */
    public function sendAddShopCategory($data = array())
    {        
        $postData = $this->getPostData($data);

        $this->DLOG("addShopCategory : " . json_encode($postData), "run", "channel_jddj");

        $res = $this->sendData('pms/addShopCategory', $postData);

        $this->DLOG("addShopCategory_res : " . json_encode($res, JSON_UNESCAPED_UNICODE), "run", "channel_jddj");

        return $res['data'];
    }

    /** 更新药品分类
     * @param $id 店内分类id
     * @param $shopCategoryName 店内分类名称
     */
    public function updateShopCategory($id, $shopCategoryName)
    {
        $data = array();
        $data['id'] = $id;
        $data['shopCategoryName'] = $shopCategoryName;

        return $data;
    }
    /** 
     * 发送更新药品分类
     */
    public function sendUpdateShopCategory($data = array())
    {        
        $postData = $this->getPostData($data);

        $this->DLOG("updateShopCategory : " . json_encode($postData), "run", "channel_jddj");

        $res = $this->sendData('pms/updateShopCategory', $postData);

        $this->DLOG("updateShopCategory_res : " . json_encode($res, JSON_UNESCAPED_UNICODE), "run", "channel_jddj");

        return $res['data'];
    }

    /** 删除药品分类
     * @param $id 店内分类id
     */
    public function delShopCategory($id)
    {
        $data = array();
        $data['id'] = $id;

        return $data;
    }
    /** 
     * 发送删除药品分类
     */
    public function sendDelShopCategory($data = array())
    {        
        $postData = $this->getPostData($data);

        $this->DLOG("delShopCategory : " . json_encode($postData), "run", "channel_jddj");

        $res = $this->sendData('pms/delShopCategory', $postData);

        $this->DLOG("delShopCategory_res : " . json_encode($res, JSON_UNESCAPED_UNICODE), "run", "channel_jddj");

        return $res['data'];
    }

    /** 查询门店药品分类列表
     * @param $fields 定义需要返回的字段列表
     */
    public function queryCategoriesByOrgCode($fields)
    {
        $data = array();
        $data['fields'] = $fields;

        return $data;
    }
    /** 
     * 发送查询门店药品分类列表
     */
    public function sendQueryCategoriesByOrgCode($data = array())
    {        
        $postData = $this->getPostData($data);

        $this->DLOG("queryCategoriesByOrgCode : " . json_encode($postData), "run", "channel_jddj");

        $res = $this->sendData('pms/queryCategoriesByOrgCode', $postData);

        $this->DLOG("queryCategoriesByOrgCode_res : " . json_encode($res, JSON_UNESCAPED_UNICODE), "run", "channel_jddj");

        return $res;
    }
}